package com.foreknow.demo13;

public class Test {
    public void showInfo(){

    }

    public static void main(String[] args) {
        Animal animal = new Cat();
        animal.setName("小猫咪 ");
        animal.shout();
        animal = new Duck();
        animal.setName("大鸭子 ");
        animal.shout();

        Animal[] animals = new Animal[2];
        Cat cat  = new Cat();
        cat.setName("Tom");
        cat.setLegNum(4);

        Duck duck = new Duck();
        duck.setName("gag");
        duck.setLegNum(2);
        animals[0] = cat;
        animals[1] = duck;

        for (int i=0 ;i < animals.length;i++){
            Animal a = animals[i];
            System.out.println(a.getLegNum() + "条腿" + a.getName());
        }
    }
}
